package cn.com.dhcc.ddi.task.service;

import cn.com.dhcc.app.core.exception.DaoException;
import cn.com.dhcc.app.core.exception.ServiceException;
import cn.com.dhcc.app.core.service.BaseService;
import cn.com.dhcc.ddi.task.dao.TaskFilterDao;
import cn.com.dhcc.ddi.task.vo.TaskFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @日期：2017/5/8 11:34
 * @作者：张洪涛
 * @版权所有：东华软件
 * @版本：1.0
 */
@Service
public class TaskFilterService extends BaseService {
    @Autowired
    private TaskFilterDao taskFilterDao;

    /**
     *新增
     * @param vo
     * @return
     * @throws ServiceException
     */
    public int addTaskFilter(TaskFilter vo) throws ServiceException {
        try {
            return taskFilterDao.insertTaskFilter(vo);
        } catch (DaoException e) {
            throw new ServiceException(e);
        }
    }

    /**
     * 修改
     * @param vo
     * @return
     * @throws ServiceException
     */
    public int updateTaskFilter(TaskFilter vo) throws ServiceException {
        try {
            return taskFilterDao.updateTaskFilter(vo);
        } catch (DaoException e) {
            throw new ServiceException(e);
        }
    }

    /**
     * 查询
     * @param taskId 任务id
     * @return
     * @throws ServiceException
     */
    public TaskFilter searchTaskFilterByTaskId(String taskId) throws ServiceException {
        try {
            return taskFilterDao.getTaskFilterByTaskId(taskId);
        } catch (DaoException e) {
            throw new ServiceException(e);
        }
    }

    /**
     * 删除过滤条件
     * @param taskId 任务id
     * @return
     * @throws ServiceException
     */
    public int deleteTaskFilterByTaskId(String taskId) throws ServiceException {
        try {
            return taskFilterDao.deleteTaskFilterByTaskId(taskId);
        } catch (DaoException e) {
            throw new ServiceException(e);
        }
    }
}
